package cn.tedu.baking.controller;

import cn.tedu.baking.mapper.UserMapper;
import cn.tedu.baking.pojo.vo.UserAdminVO;
import cn.tedu.baking.response.JsonResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class AxiosController {
//
    @GetMapping("/h1")
    public String h1(String info){
        System.out.println(info);
        return info;
    }
//    测试post请求
    @PostMapping("/h2")
    public String h2(@RequestBody String info){
        System.out.println(info);
        return info;
    }

    @Autowired
    UserMapper userMapper;

    @GetMapping("/list1")
    @ApiOperation(value = "查询所有用户功能")
    public List<UserAdminVO> selectAll1(){
        List<UserAdminVO> list=userMapper.selectAllUser();
//         return list;
//        r.data
        return list;
    }


    @GetMapping("/list2")
    @ApiOperation(value = "查询所有用户功能")
    public JsonResult selectAll2(){
        List<UserAdminVO> list=userMapper.selectAllUser();
        return JsonResult.ok(list);
    }
}
